#include <QApplication>
#include <QFile>
#include <QTextStream>
#include "previewer_widget.h"

void load_style(const QString& qss_file)
{
    //加载样式表
    QString qss;
    QFile file(qss_file);
    if (file.open(QFile::ReadOnly)) {
        //用QTextStream读取样式文件不用区分文件编码 带bom也行
        QStringList list;
        QTextStream in(&file);
        //in.setCodec("utf-8");
        while (!in.atEnd()) {
            QString line;
            in >> line;
            list << line;
        }

        file.close();
        qss = list.join("\n");
        QString palette_color = qss.mid(20, 7);
        qApp->setPalette(QPalette(palette_color));
        //用时主要在下面这句
        qApp->setStyleSheet(qss);
    }
}

int main(int argc, char *argv[])
{
	QApplication app(argc, argv);

    load_style(":/qss/flatgray.css");

	PreviewerWidget w;
	w.show();

	return app.exec();
}

